package com.hzz.dao.river;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.hzz.dto.analysis.RiverInfoStatDto;
import com.hzz.entity.river.RiverInfo;
import com.hzz.framework.dao.IBaseDao;
import com.hzz.framework.entity.IEntity;

/**
 * <p>河道名录 数据库处理接口类。
 */
@Mapper
public interface IRiverInfoDao extends IBaseDao {

    /**
      * 判断是否存在
      */
    @Override
	@Select("select IFNULL(count(0),0) as count from river_info where  id = #{id} ")
    int isDataExist(IEntity entity) throws Exception;

    /**
     * 逻辑删除
     */
    @Override
	@Update("update river_info set  date_updated=now(), del_flag=1 where  id = #{id} ")
    int deleteById(IEntity entity) throws Exception;


    /**
     * 根据主键 物理删除
     */
    @Override
	@Delete("delete from river_info where  id = #{id} ")
    int deleteByPrimaryKey(IEntity entity) throws Exception;

	/**
	 * 根据行政区划ID按等级统计下级河道数量(图表用)
	 *
	 * @param currAreaId
	 * @return
	 */
	List<RiverInfoStatDto> statLevelNumByParentAreaId(@Param("currAreaId") Long currAreaId);

	/**
	 * 根据行政区划ID按下级区划名称统计乡镇级和村级河道数量（列表用）
	 *
	 * @param entity
	 * @return
	 */
	List<RiverInfoStatDto> statNameNumByParentAreaId(RiverInfo entity);

	/**
	 * 查询总河段总量
	 *
	 * @return
	 */
	@Select("select IFNULL(count(0),0) as count from river_info where type=#{type} and del_flag=0 ")
	int getTotalNum(Integer type);

	List findDataListByUserId(IEntity entity);
}
